import req from '@/apis/http';
import configs from '@/config';
import { jsonp } from 'vue-jsonp';

const jsonpParam = { datatype: 'jsonp' };
const apigatePrefix = '//apigate.10jqka.com.cn/d/charge/gpcapi';
const gpcPrefix = '//gpc.10jqka.com.cn/gpcapi';

export const cfxfJudgeAuth = params =>
  jsonp(configs.api.getuserlimit, { ...jsonpParam, ...params });

// 获取观察池列表
export const reqJuniorPool = params =>
  req('get', '//dq.10jqka.com.cn/fuyao/b2cweb_gpc_sector_opportunity/gpc/v1/gpc/backup', '', {
    ...params,
  });

// 获取精选池列表
export const reqSelectedPool = params =>
  req('get', `${gpcPrefix}/ggzc/pickStocks`, '', {
    ...params
  });

// 持仓分析
export const reqPoolProfit = params =>
  req('get', `${gpcPrefix}/ggzc/profit`, '', {
    ...params
  });

// 跟踪池设置信息
export const reqBuyStrategy = params =>
  req('get', `${apigatePrefix}/trace_gpc/v1/query_account`, '', {
    ...params,
  });

// 获取跟踪池列表
export const reqTrackPool = params =>
  req('get', `${apigatePrefix}/trace_gpc/v1/query_stock`, '', {
    ...params
  });

export const reqPoolSub = () =>
  req('get', `${apigatePrefix}/push/gpc_trace/v1/latest`, '', {
    version: 1,
  });

// 精选池/跟踪池-查询股票池下多只股票的跟踪消息
export const reqSignalList = params =>
  req('post', `${apigatePrefix}/push/gpc_trace/v1/batch`, '', {
    ...params
  });

export const reqSubInfo = params =>
  req('get', `${apigatePrefix}/trace_gpc/v1/subscribe_info`, '', {
    ...params,
  });

export const setSub = params =>
  req('get', `${apigatePrefix}/trace_gpc/v1/subscribe`, '', {
    ...params,
  });

export const reqTraceGpcCondition = params =>
  req('get', `${apigatePrefix}/trace_gpc/v1/query_condition`, '', {
    ...params,
  });

export const setTraceGpc = params =>
  req('post', `${apigatePrefix}/trace_gpc/v1/init`, '', {
    ...params,
  });
